package util.lang.sql;

public enum SqlOrderByType {
	None("", 0),
	Ascend("ASC", 1),
	Descend("DESCEND", 2);
	
	private String sqlKeyword;
	private short nCode;

    private SqlOrderByType(String sqlKeyword, short nCode) {
    	this.sqlKeyword = sqlKeyword;
        this.nCode = nCode;
    }
    private SqlOrderByType(String sqlKeyword, int nCode) {
    	this.sqlKeyword = sqlKeyword;
        this.nCode = (short)nCode;
    }
    
    public String getSqlKeyword() {
    	return this.sqlKeyword;
    }
    
    public short getCode() {
    	return this.nCode;
    }

    public static SqlOrderByType fromCode(short ncode) {
    	switch(ncode) {
    	case 0:return SqlOrderByType.None;
    	case 1:return SqlOrderByType.Ascend;
    	case 2:return SqlOrderByType.Descend;
    	default : return SqlOrderByType.None;
    	}
    }
    
    public static SqlOrderByType fromCode(int ncode) {
    	switch((short)ncode) {
    	case 0:return SqlOrderByType.None;
    	case 1:return SqlOrderByType.Ascend;
    	case 2:return SqlOrderByType.Descend;
    	default : return SqlOrderByType.None;
    	}
    }
}